import Vue from 'vue'
export const item =  (function(){
     const items = [ 
                    {name:'axe'},{name:'earthshaker'}, {name:'pudge'},{name:'sand_king'},{name:'sven'},
                    {name:'tiny'},{name:'kunkka'},{name:'slardar'},{name:'tidehunter'},{name:'beastmaster'},{name:'skeleton_king'},
                    {name:'dragon_knight'},{name:'rattletrap'},{name:'life_stealer'},{name:'omniknight'},{name:'huskar'},{name:'night_stalker'},{name:'doom_bringer'},
                    {name:'spirit_breaker'},{name:'alchemist'},{name:'lycan'},{name:'brewmaster'},{name:'chaos_knight'},{name:'treant'},
                    {name:'undying'},{name:'wisp'},{name:'centaur'},{name:'magnataur'},{name:'shredder'},{name:'bristleback'},{name:'tusk'},{name:'abaddon'},
                    {name:'elder_titan'},{name:'legion_commander'},{name:'earth_spirit'},{name:'phoenix'},{name:'antimage'},{name:'bloodseeker'},{name:'drow_ranger'},
                    {name:'juggernaut'},{name:'mirana'},{name:'morphling'},{name:'nevermore'},{name:'phantom_lancer'},{name:'razor'},{name:'vengefulspirit'},
                    {name:'riki'},{name:'sniper'},{name:'venomancer'},{name:'faceless_void'},{name:'phantom_assassin'},
                    {name:'templar_assassin'},{name:'viper'},{name:'luna'},{name:'clinkz'},{name:'broodmother'},{name:'bounty_hunter'},
                    {name:'weaver'},{name:'spectre'},{name:'ursa'},{name:'gyrocopter'},{name:'lone_druid'},{name:'meepo'},
                    {name:'nyx_assassin'},{name:'naga_siren'},{name:'slark'},{name:'medusa'},{name:'troll_warlord'},{name:'ember_spirit'},
                    {name:'terrorblade'},{name:'arc_warden'},{name:'bane'},{name:'crystal_maiden'},{name:'puck'},{name:'storm_spirit'},
                    {name:'windrunner'}, {name:'zuus'}, {name:'lina'}, {name:'lion'}, {name:'shadow_shaman'}, {name:'witch_doctor'}, {name:'lich'},
                    {name:'enigma'}, {name:'tinker'}, {name:'necrolyte'}, {name:'warlock'}, {name:'queenofpain'}, {name:'death_prophet'},
                    {name:'pugna'}, {name:'dazzle'}, {name:'leshrac'}, {name:'furion'}, {name:'dark_seer'}, {name:'enchantress'}, 
                    {name:'jakiro'}, {name:'batrider'}, {name:'chen'}, {name:'ancient_apparition'}, {name:'invoker'}, {name:'silencer'},
                    {name:'obsidian_destroyer'}, {name:'shadow_demon'}, {name:'ogre_magi'}, {name:'rubick'}, {name:'disruptor'},
                    {name:'keeper_of_the_light'}, {name:'visage'}, {name:'skywrath_mage'}, {name:'techies'}, {name:'oracle'}, {name:'winter_wyvern'}
                    ] ;
    var str ="";
    // 纯前端无法请求一个界面获取一个界面的内容,需要后端的支持.
    // Vue.http.jsonp('https://github.com/EliazTray/vue-resource/blob/master/docs/http.md').then((resolve)=>{
    //    str = resolve.text();
    // },(reject)=>{
    //     console.log(reject)
    // })
   
    const getItem =function(){
        // str.replace(/<img\ssrc=[\'"](.+?)[\'"]\>/gi,function(match, capture){
        //     items.push(capture);
        //     console.log(items);
        // })
        items.forEach((item)=>{
            item.src = 'http://cdn.dota2.com/apps/dota2/images/heroes/'+ item.name +'_hphover.png';
        })
        return items;
    }
    return {
        get : getItem
    }
})()